<?php

App::uses('AppModel', 'Model');

class ShipperModel extends Model {
    public $useTable = 'm_shipper';

    // Use primaryKey
    public $primaryKey = 'id';

    public function getInfoFrmShipper($mode) {
        $params = array();
        // Set fields params
        $params['fields'] = array(	
        						   'ShipperModel.id',
        						   'ShipperModel.shipper_cd',
                                   'ShipperModel.shipper_name',
                                   'ShipperModel.store_unit_price',
                                   'ShipperModel.im_ex_unit_price',
                                   );
        // Set condition params
        if ($mode != 'list')  {
	        $params['conditions'] = array('OR' => array('ShipperModel.store_unit_price' => '0',
	                                                    'ShipperModel.im_ex_unit_price' => '0'
	                                                    )
	                                     );
		}
        return $this->find('all', $params);
    }

	// get shipper list for image pdf creation
	public function getShipperListForImagePDF() {
        $params['fields'] = array('ShipperModel.shipper_cd, ShipperModel.shipper_name');
        // Set condition params
        $params['conditions'] = array(
        					"coalesce(ShipperModel.shipper_cd,'0') <> " => '0',
        					"coalesce(ShipperModel.shipper_name,'0') <> " => '0'
                           );

        return $this->find('all', $params);
	}
}
